function getJedisPool(){
let JedisPoolConfig=Java.type("redis.clients.jedis.JedisPoolConfig");
let jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(Jse.conf.getInt("jse.redis.jedis.pool.max-active",8));//最大连接数
if(Jse.conf.containsKey("jse.redis.jedis.pool.max-idle"))
jedisPoolConfig.setMaxIdle(Jse.conf.getInt("jse.redis.jedis.pool.max-idle"));//最多8个活动连接
if(Jse.conf.containsKey("jse.redis.jedis.pool.min-idle"))
jedisPoolConfig.setMinIdle(Jse.conf.getInt("jse.redis.jedis.pool.min-idle"));
if(Jse.conf.containsKey("jse.redis.jedis.pool.max-wait"))
jedisPoolConfig.setMaxWait(java.time.Duration.ofSeconds(Jse.conf.getLong("jse.redis.jedis.pool.max-wait")));//最大等待时间
//jedisPoolConfig.setTestOnBorrow(true);//检查连接是否有效，默认不检查
let JedisPool=Java.type("redis.clients.jedis.JedisPool");
if(Jse.conf.containsKey("jse.redis.password"))return new JedisPool(jedisPoolConfig,
					Jse.conf.getString("jse.redis.host","127.0.0.1"),
					Jse.conf.getInt("jse.redis.port",6379),
					Jse.conf.getInt("jse.redis.timeout",3000),
					Jse.conf.getString("jse.redis.password"));
else return new JedisPool(jedisPoolConfig,
					Jse.conf.getString("jse.redis.host","127.0.0.1"),
					Jse.conf.getInt("jse.redis.port",6379),
					Jse.conf.getInt("jse.redis.timeout",3000));
}
var JedisCacheListener=Java.extend(Java.type("com.jse.Cache.CacheListener"), {
	get:(k)=>{
		var jedis=null;
		try{
		jedis=jedisPool.getResource();
		print("jedis get:"+k)
		return jedis.get(k);
		}catch(e){throw e}
		finally{if(jedis!=null)jedis.close();}
	},
	put:(k,v,t)=>{
		var jedis=null;
				try{
				jedis=jedisPool.getResource();
				print(`jedis put:${k}=${v} ttl=${t}ms`)
				if(t<1){jedis.set(k,v);}
				else jedis.setex(k,t/1000,v);
				}catch(e){e.printStackTrace();throw e}
				finally{if(jedis!=null)jedis.close();}
	},
	remove:(k)=>{
		var jedis=null;
				try{
				jedis=jedisPool.getResource();
				print("jedis del:"+k)
				jedis.del(k);
				}catch(e){throw e}
				finally{if(jedis!=null)jedis.close();}
	},
	init(){
		var jedis=null;
		try{
		jedis=jedisPool.getResource();
		jedis.keys(Jse.redisPrefix+"*").forEach(function(k){
			let v=jedis.get(k);
			print("jedis init " + k + "=" + v);
			if(v[0]=='{'||v[0]=='[')v=Json.parse(v);
			Jse.cache.put(k,v,jedis.ttl(k)*1000)
		})
		}catch(e){throw e}
		finally{if(jedis!=null)jedis.close();}
	}
});
var jedisListener=new JedisCacheListener();